﻿@model IPagedList<User>

@{
    ViewBag.Title = "Manage Users";
}
<script src="@Url.Content("~/Assets/Scripts/lib/jquery.undoable.js")" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
    $('a.delete').undoable({
        url: '@Url.Action("Delete", "Users")',
        getPostData: function (clickSource, target) {
            return {
                id: clickSource.parents('tr').attr('id')
            };
        }
    });
});
</script>


<h1>Users</h1>

@Html.Partial("_UserMenu")

<table class="full">
    <thead>
        <tr>
            <th id="usernameColumn">Username</th>
            <th id="roleColumn">Role</th>
            <th id="createdColumn">Created</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
    @if (Model.Count == 0) {
        <tr>
            <td colspan="4">No users found.</td>
        </tr>
    }
    @foreach (var user in Model) {
        <tr id="@user.UserId">
            <td><a href="@user.Link" class="user">@user.Username</a></td>
            <td>@user.Role</td>
            <td>@Html.DisplayFor(m => user.DateCreated)</td>
            <td class="alignRight">
                @Html.ActionLink("Edit", "Edit", new { id = user.UserId }, new { @class = "lightButton" }) 
                @Html.ActionLink("Delete", "Delete", new { id = user.UserId }, new { @class = "lightButton delete" })
            </td>
        </tr>
    }
    </tbody>
    <tfoot>
        <tr>
            <td colspan="4" class="alignRight">
                @if (Model.PageCount > 1) {
                    @Html.Pager(Model)
                }
            </td>
        </tr>
    </tfoot>
</table>




